package so.sao.code.service.repository;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import so.sao.code.service.domain.entity.ThirdPartyCodeFileRecord;


/**
 * 
 * @author 
 *
 */
@Repository
public interface ThirdPartyCodeFileRecordDao extends JpaRepository<ThirdPartyCodeFileRecord, Long> {


	ThirdPartyCodeFileRecord findByCompanyIdAndFileName(Long companyId, String fileName);
	
	 @Query(value = "select TOP 1 * from third_Party_Code_File_Record  where scheduler = ?1 and exception = ?2 ORDER BY id ASC", nativeQuery = true)
	ThirdPartyCodeFileRecord findOneBySchedulerAndException(Integer scheduler, Integer exception);
	 
	 //TODO 需要修改。
	 @Query(value = "select TOP 1 * from third_Party_Code_File_Record  where scheduler = ?1 and exception = ?2 ORDER BY id ASC", nativeQuery = true)
	ThirdPartyCodeFileRecord findOneBySchedulerAndExceptionForSendFFW(Integer scheduler, Integer exception);
	
	List<ThirdPartyCodeFileRecord> findByCompanyIdAndCreateDateAfter(Long companyId, Date createDate);
		
}
